# import tkinter as tk
# import time
# root = tk.Tk()
# root.title("C语言中文网")

# root.geometry('450x150+100+100')
# root.resizable(0,0)
# root.title('我们的时钟')

# # 获取时间的函数
# def gettime():
#     # 获取当前时间
#     dstr.set(time.strftime("%H:%M:%S"))
#     # 每隔 1s 调用一次 gettime()函数来获取时间
#     root.after(1000, gettime)
# # 生成动态字符串
# dstr = tk.StringVar()
# # 利用 textvariable 来实现文本变化
# lb = tk.Label(root,textvariable=dstr,fg='green',font=("微软雅黑",85))
# lb.pack()
# # 调用生成时间的函数
# gettime()
# # 显示窗口
# root.mainloop()

# import tkinter as tk
# win = tk.Tk()
# win.title("C语言中文网")
# win.geometry('400x200')

# # 若内容是文字则以字符为单位，图像则以像素为单位
# label = tk.Label(win, text="网址：c.biancheng.net",font=('宋体',20, 'bold italic'),bg="#7CCD7C",
#                  # 设置标签内容区大小
#                  width=30,height=5,
#                  # 设置填充区距离、边框宽度和其样式（凹陷式）
#                  padx=10, pady=15, borderwidth=10, relief="sunken")
# label.pack()
# win.mainloop()

# import tkinter as tk
# from tkinter import messagebox

# window = tk.Tk()
# # 设置窗口的标题
# window.title('C语言中文网')
# # 设置窗口的大小
# window.geometry('400x300+300+200')

# # 当按钮被点击的时候执行click_button()函数
# def click_button():
#     # 使用消息对话框控件，showinfo()表示温馨提示
#     messagebox.showinfo(title='温馨提示', message='欢迎使用C语言中文网')
# # 创建图片对象
# im = tk.PhotoImage(file='C:/Users/Administrator/Desktop/按钮.gif')
# # 通过image参数传递图片对象
# button = tk.Button(window,image=im,command=click_button).pack()
# # 启动窗口
# window.mainloop()

# import tkinter as tk
# from tkinter import messagebox

# win = tk.Tk()
# win.title("C语言中文网")
# # win.iconbitmap('C:/Users/Administrator/Desktop/C语言中文网logo.ico')
# win.geometry('400x200+100+100')
# win.resizable(0,0)

# # 将俩个标签分别布置在第一行、第二行
# tk.Label(win, text="账号：").grid(row=0)
# tk.Label(win, text="密码：").grid(row=1)
# # 创建输入框控件
# e1 = tk.Entry(win)
# # 以 * 的形式显示密码
# e2 = tk.Entry(win,show='*')
# e1.grid(row=0, column=1, padx=10, pady=5)
# e2.grid(row=1, column=1, padx=10, pady=5)

# # 编写一个简单的回调函数
# def login():
#     messagebox.showinfo('欢迎您到来')

# # 使用 grid()的函数来布局，并控制按钮的显示位置
# tk.Button(win, text="登录", width=10, command=login).grid(row=3, column=0, sticky="w", padx=10, pady=5)
# tk.Button(win, text="退出", width=10, command=win.quit).grid(row=3, column=1, sticky="e", padx=10, pady=5)

# win.mainloop()

# import tkinter as tk
# from tkinter import messagebox
# import re

# win = tk.Tk()
# # 设置主窗口
# win.geometry('300x200+250+200')
# win.title("C语言中文网")

# # win.iconbitmap('C:/Users/Administrator/Desktop/C语言中文网logo.ico')
# win.resizable(0,0)

# # 创建验证函数
# def check():
#     # 验证账号是否为数字
#     if not entry1.get().isdigit():
#         messagebox.showwarning("输入不正确", "账号必须为数字")
#         entry1.delete(0, tk.END)
#         return False
    
#     # 验证密码是否符合要求
#     password = entry2.get()
#     if len(password) < 8:
#         messagebox.showwarning("输入不正确", "密码长度必须至少8个字符")
#         entry2.delete(0, tk.END)
#         return False
    
#     # 检查是否包含大写字母
#     if not re.search(r'[A-Z]', password):
#         messagebox.showwarning("输入不正确", "密码必须包含至少一个大写字母")
#         entry2.delete(0, tk.END)
#         return False
    
#     # 检查是否包含小写字母
#     if not re.search(r'[a-z]', password):
#         messagebox.showwarning("输入不正确", "密码必须包含至少一个小写字母")
#         entry2.delete(0, tk.END)
#         return False
    
#     # 检查是否包含特殊字符
#     if not re.search(r'[!@#$%^&*(),.?":{}|<>]', password):
#         messagebox.showwarning("输入不正确", "密码必须包含至少一个特殊字符 (!@#$%^&*等)")
#         entry2.delete(0, tk.END)
#         return False
    
#     # 所有验证通过
#     messagebox.showinfo("输入正确", "账号和密码格式正确！")
#     return True

# # 新建文本标签
# labe1 = tk.Label(win, text="账号：")
# labe2 = tk.Label(win, text="密码：")
# labe1.grid(row=0, sticky="e", padx=5, pady=10)
# labe2.grid(row=1, sticky="e", padx=5, pady=10)

# # 创建输入框
# entry1 = tk.Entry(win)
# entry2 = tk.Entry(win, show="*")  # 密码显示为*

# # 对控件进行布局管理，放在文本标签的后面
# entry1.grid(row=0, column=1, padx=5, pady=10)
# entry2.grid(row=1, column=1, padx=5, pady=10)

# # 添加登录按钮
# login_btn = tk.Button(win, text="登录", command=check)
# login_btn.grid(row=2, column=0, columnspan=2, pady=10)

# # 添加说明标签
# info_label = tk.Label(win, text="密码要求: 大小写字母+特殊字符+长度≥8", font=("Arial", 8), fg="gray")
# info_label.grid(row=3, column=0, columnspan=2)

# win.mainloop()

# import tkinter as tk

# root = tk.Tk()
# root.title("C语言中文网")
# root.geometry('300x200+300+300')
# # root.iconbitmap('C:/Users/Administrator/Desktop/C语言中文网logo.ico')
# # 使用 values 参数以元组的形式进行传参
# strings = tk.Spinbox(root,values=('Python','java','C语言','PHP'))
# strings.pack()
# # 开启事件循环
# root.mainloop()

# from tkinter import *
# import tkinter . messagebox
# #创建主窗口
# win = Tk()
# win.config(bg='#87CEEB')
# win.title("C语言中文网")
# win.geometry('450x350+300+200')


# # 绑定一个执行函数，当点击菜单项的时候会显示一个消息对话框
# def menuCommand() :
#     tkinter.messagebox.showinfo("主菜单栏","你正在使用主菜单栏")
# # 创建一个主目录菜单，也被称为顶级菜单
# main_menu = Menu (win)
# #新增命令菜单项，使用 add_command() 实现
# main_menu.add_command (label="文件",command=menuCommand)
# main_menu.add_command (label="编辑",command=menuCommand)
# main_menu.add_command (label="格式",command=menuCommand)
# main_menu.add_command (label="查看",command=menuCommand)
# main_menu.add_command (label="帮助",command=menuCommand)
# #显示菜单
# win.config (menu=main_menu)
# win.mainloop()


# import tkinter as tk

# root = tk.Tk()
# root.config(bg='#8DB6CD')
# root.title("C语言中文网")
# root.geometry('400x300')
# # root.iconbitmap('C:/Users/Administrator/Desktop/C语言中文网logo.ico')
# def func():
#     print('您通过弹出菜单执行了命令')

# # 创建一个弹出菜单
# menu = tk.Menu(root, tearoff=False)
# menu.add_command(label="新建", command=func)
# menu.add_command(label="复制", command=func)
# menu.add_command(label="粘贴", command=func)
# menu.add_command(label="剪切", command=func)
# # 定义事件函数
# def command(event):
#     # 使用 post()在指定的位置显示弹出菜单
#     menu.post(event.x_root, event.y_root)
   
# # 绑定鼠标右键，这是鼠标绑定事件
# # <Button-3>表示点击鼠标的右键，1 表示左键，2表示点击中间的滑轮
# root.bind("<Button-3>", command)
# root.mainloop()



# from tkinter import *
# from tkinter import messagebox, filedialog, scrolledtext
# import os

# # 创建主窗口
# win = Tk()
# win.config(bg='#87CEEB')
# win.title("C语言中文网文本编辑器")
# win.geometry('600x500+300+200')
# # win.iconbitmap('C:/Users/Administrator/Desktop/C语言中文网logo.ico')

# # 当前文件路径
# current_file = None

# # 创建文本编辑区域
# text_area = scrolledtext.ScrolledText(win, wrap=WORD, font=("Consolas", 12))
# text_area.pack(fill=BOTH, expand=True, padx=10, pady=10)

# # 状态栏
# status_bar = Label(win, text="就绪 | 行: 1 列: 1", bd=1, relief=SUNKEN, anchor=W)
# status_bar.pack(side=BOTTOM, fill=X)

# def update_status_bar(event=None):
#     """更新状态栏信息"""
#     if text_area.compare("end-1c", "!=", "1.0"):
#         # 获取当前光标位置
#         cursor_pos = text_area.index(INSERT)
#         line, col = cursor_pos.split('.')
#         status_bar.config(text=f"就绪 | 行: {line} 列: {int(col)+1} | 文件: {current_file if current_file else '未命名'}")
#     else:
#         status_bar.config(text="就绪 | 新建文件")

# # 绑定文本区域的事件
# text_area.bind('<KeyRelease>', update_status_bar)
# text_area.bind('<ButtonRelease>', update_status_bar)

# def new_file(event=None):
#     """新建文件"""
#     global current_file
#     if text_area.get(1.0, END).strip():
#         if messagebox.askyesno("新建文件", "当前内容未保存，是否继续新建？"):
#             text_area.delete(1.0, END)
#             current_file = None
#             win.title("C语言中文网文本编辑器 - 未命名")
#             update_status_bar()
#     else:
#         text_area.delete(1.0, END)
#         current_file = None
#         win.title("C语言中文网文本编辑器 - 未命名")
#         update_status_bar()

# def open_file(event=None):
#     """打开文件"""
#     global current_file
#     file_path = filedialog.askopenfilename(
#         title="打开文件",
#         filetypes=[
#             ("文本文件", "*.txt"),
#             ("Python文件", "*.py"),
#             ("所有文件", "*.*")
#         ]
#     )
    
#     if file_path:
#         try:
#             with open(file_path, 'r', encoding='utf-8') as file:
#                 content = file.read()
#                 text_area.delete(1.0, END)
#                 text_area.insert(1.0, content)
#                 current_file = file_path
#                 win.title(f"C语言中文网文本编辑器 - {os.path.basename(file_path)}")
#                 update_status_bar()
#                 messagebox.showinfo("成功", f"已打开文件: {os.path.basename(file_path)}")
#         except Exception as e:
#             messagebox.showerror("错误", f"打开文件失败: {str(e)}")

# def save_file(event=None):
#     """保存文件"""
#     global current_file
#     if current_file:
#         try:
#             with open(current_file, 'w', encoding='utf-8') as file:
#                 content = text_area.get(1.0, END)
#                 file.write(content)
#             messagebox.showinfo("成功", "文件已保存")
#             return True
#         except Exception as e:
#             messagebox.showerror("错误", f"保存文件失败: {str(e)}")
#             return False
#     else:
#         return save_as_file()

# def save_as_file(event=None):
#     """另存为文件"""
#     global current_file
#     file_path = filedialog.asksaveasfilename(
#         title="另存为",
#         defaultextension=".txt",
#         filetypes=[
#             ("文本文件", "*.txt"),
#             ("Python文件", "*.py"),
#             ("所有文件", "*.*")
#         ]
#     )
    
#     if file_path:
#         try:
#             with open(file_path, 'w', encoding='utf-8') as file:
#                 content = text_area.get(1.0, END)
#                 file.write(content)
#             current_file = file_path
#             win.title(f"C语言中文网文本编辑器 - {os.path.basename(file_path)}")
#             messagebox.showinfo("成功", f"文件已保存为: {os.path.basename(file_path)}")
#             update_status_bar()
#             return True
#         except Exception as e:
#             messagebox.showerror("错误", f"保存文件失败: {str(e)}")
#             return False
#     return False

# def exit_editor(event=None):
#     """退出编辑器"""
#     if text_area.get(1.0, END).strip():
#         result = messagebox.askyesnocancel("退出", "文件未保存，是否保存后退出？")
#         if result is None:  # 取消
#             return
#         elif result:  # 是（保存）
#             if not save_file():
#                 return  # 如果保存失败，不退出
    
#     win.quit()

# def cut_text(event=None):
#     """剪切文本"""
#     text_area.event_generate("<<Cut>>")

# def copy_text(event=None):
#     """复制文本"""
#     text_area.event_generate("<<Copy>>")

# def paste_text(event=None):
#     """粘贴文本"""
#     text_area.event_generate("<<Paste>>")

# def select_all(event=None):
#     """全选文本"""
#     text_area.tag_add(SEL, "1.0", END)
#     text_area.mark_set(INSERT, "1.0")
#     text_area.see(INSERT)
#     return 'break'

# def about():
#     """关于信息"""
#     messagebox.showinfo("关于", "C语言中文网文本编辑器\n版本 1.0\n\n一个简单的文本编辑工具")

# # 创建主菜单
# mainmenu = Menu(win)

# # 文件菜单
# filemenu = Menu(mainmenu, tearoff=False)
# filemenu.add_command(label="新建", command=new_file, accelerator="Ctrl+N")
# filemenu.add_command(label="打开", command=open_file, accelerator="Ctrl+O")
# filemenu.add_command(label="保存", command=save_file, accelerator="Ctrl+S")
# filemenu.add_command(label="另存为", command=save_as_file, accelerator="Ctrl+Shift+S")
# filemenu.add_separator()
# filemenu.add_command(label="退出", command=exit_editor, accelerator="Ctrl+Q")
# mainmenu.add_cascade(label="文件", menu=filemenu)

# # 编辑菜单
# editmenu = Menu(mainmenu, tearoff=False)
# editmenu.add_command(label="撤销", command=lambda: text_area.event_generate("<<Undo>>"), accelerator="Ctrl+Z")
# editmenu.add_command(label="重做", command=lambda: text_area.event_generate("<<Redo>>"), accelerator="Ctrl+Y")
# editmenu.add_separator()
# editmenu.add_command(label="剪切", command=cut_text, accelerator="Ctrl+X")
# editmenu.add_command(label="复制", command=copy_text, accelerator="Ctrl+C")
# editmenu.add_command(label="粘贴", command=paste_text, accelerator="Ctrl+V")
# editmenu.add_separator()
# editmenu.add_command(label="全选", command=select_all, accelerator="Ctrl+A")
# mainmenu.add_cascade(label="编辑", menu=editmenu)

# # 帮助菜单
# helpmenu = Menu(mainmenu, tearoff=False)
# helpmenu.add_command(label="关于", command=about)
# mainmenu.add_cascade(label="帮助", menu=helpmenu)

# # 设置菜单
# win.config(menu=mainmenu)

# # 绑定键盘快捷键
# win.bind("<Control-n>", new_file)
# win.bind("<Control-N>", new_file)
# win.bind("<Control-o>", open_file)
# win.bind("<Control-O>", open_file)
# win.bind("<Control-s>", save_file)
# win.bind("<Control-S>", save_file)
# win.bind("<Control-Shift-S>", save_as_file)
# win.bind("<Control-Shift-s>", save_as_file)
# win.bind("<Control-q>", exit_editor)
# win.bind("<Control-Q>", exit_editor)
# win.bind("<Control-a>", select_all)
# win.bind("<Control-A>", select_all)

# # 配置文本区域的撤销/重做功能
# text_area.config(undo=True)

# # 显示主窗口
# update_status_bar()
# win.mainloop()



# import tkinter as tk

# win = tk.Tk()
# win.title("C语言中文网")
# win.geometry('400x350+200+200')
# # win.iconbitmap('C:/Users/Administrator/Desktop/C语言中文网logo.ico')

# # 在主窗口上添加一个frame控件
# frame1 = tk.Frame(win)
# frame1.pack()

# # 在frame_1上添加另外两个frame， 一个在靠左，一个靠右
# #左侧的frame
# frame_left = tk.Frame(frame1)
# tk.Label(frame_left,text='左侧标签1',bg='green',width=10,height=5).grid(row =0,column=0)
# tk.Label(frame_left,text='左侧标签2',bg='blue',width=10,height=5).grid(row = 1 ,column =1)
# frame_left.pack(side=tk.LEFT)

# frame_right = tk.Frame(frame1)
# tk.Label(frame_right,text='右侧标签1',bg='gray',width=10,height=5).grid(row = 0 ,column =1)
# tk.Label(frame_right,text='右侧标签2',bg='pink',width=10,height=5).grid(row = 1 ,column =0)
# tk.Label(frame_right,text='右侧标签3',bg='purple',width=10,height=5).grid(row= 1,column=1)
# frame_right.pack(side=tk.RIGHT)
# win.mainloop()

from tkinter import *
#主窗口
win = Tk()
win.config(bg='#87CEEB')
win.title("C语言中文网")
win.geometry('500x350+300+300')

#在窗口内创建按钮，以表格的形式依次排列
for i in range (10):
    for j in range (10):
        Button (win, text=" (" + str(i) + ","+ str(j)+ ")",bg='#D1EEEE') .grid(row=i,column=j)

# 在第5行第11列添加一个Label标签
Label(win,text="C语言中文网",fg='blue',font=('楷体',12,'bold')).grid(row =4,column=11)
#开始窗口的事件循环
win. mainloop()